<?php

namespace App\Http\Controllers;

use App\Awardlog;
use App\MakeTable\Table;
use App\Redict\Success;
use Illuminate\Http\Request;

class AwardlogController extends Controller
{
    public function __construct()
    {
        $this->middleware('can:root_Admin_award');
    }
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        $pagename = '奖品日志';
        $modelurl = 'awardlogs';
        $tablecate = ['tablecate'=>'奖品记录'];
        $headname = ['接受者','电话','地址','邮编','奖品','接收人','状态','操作'];
        $tablehead = ['receiver','tele','address','zip_code','award','consumer','status','id'];
        $awardtable = new Table($tablehead,$page = 8);
        $model = $awardtable->viewdata(Awardlog::class);//获取视图中的数据
        $models = $awardtable->viewpagedata(Awardlog::class);//获取视图中的分页数据
        return view('admin.home.tableshow',compact('tablecate','model','tablehead','models','headname','pagename','modelurl'));
    }
    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //删除
        Awardlog::destroy($id);
        return Success::back();
    }
}
